package com.jiawa.train.business.controller.admin;

import com.jiawa.train.common.resp.PageResult;
import com.jiawa.train.common.resp.Result;
import com.jiawa.train.business.req.DailyTrainCarriageQueryReq;
import com.jiawa.train.business.req.DailyTrainCarriageSaveReq;
import com.jiawa.train.business.service.DailyTrainCarriageService;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/dailyTrainCarriage")
@Slf4j
public class DailyTrainCarriageAdminController {

    @Resource
    private DailyTrainCarriageService dailyTrainCarriageService;
    @PostMapping("/save")
    public Result save(@RequestBody @Valid DailyTrainCarriageSaveReq req) {
        dailyTrainCarriageService.save(req);
        return Result.success();
    }
    @GetMapping("/page")
    public Result<PageResult> queryDailyTrainCarriageList(DailyTrainCarriageQueryReq  req) {
       PageResult pageResult = dailyTrainCarriageService.queryDailyTrainCarriageList(req);
       return Result.success(pageResult);
    }
    @DeleteMapping("/delete/{id}")
    public Result delete(@PathVariable Long id) {
        dailyTrainCarriageService.delete(id);
        return Result.success();
    }
}

